﻿using Dapper;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Finance.Infrastructure
{
    public class DapperDb : IDapperDb
    {
        private readonly IDbConnection _db;

        public DapperDb(IDbConnection db)
        {
            _db = db;
        }

        public async Task<IEnumerable<T>> Query<T>(string sql, object parameters = null)
        {
            return await _db.QueryAsync<T>(sql, parameters);
        }

        public async Task<T> QueryFirst<T>(string sql, object parameters = null)
        {
            return await _db.QueryFirstAsync<T>(sql, parameters);
        }
    }
}
